'''
@author: saaj
@license: LGPL
'''


import cherrypy
import os.path
import qxcpjsonrpc as rpc
from cherrypy.lib.static import serve_file


class Root:

  def __init__(self):
    self.service = Service() 
    
  @cherrypy.expose
  def index(self):
    return serve_file(os.path.join(cherrypy.thread_data.path, "variable/frontend/index.html"))
  
  @cherrypy.expose
  def script(self, *args):
    path = os.path.join(cherrypy.thread_data.path, "variable/frontend")
    return serve_file(os.path.join(path, os.path.basename(args[0])))

  
class Service:

  @cherrypy.expose
  def index(self, *args, **kwargs):
    return rpc.JsonRpcServer().run()